package com.util;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class FileUtils {

	public static void write(String path,String msg) {
		try {
			File file = new File(path);
			if(!file.exists()){
				file.getParentFile().mkdirs();
			}
			// 使用这个构造函数时，如果存在kuka.txt文件，
			// 则先把这个文件给删除掉，然后创建新的kuka.txt
			FileWriter writer = new FileWriter(path,true);
			writer.append(msg+"\n");
			writer.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	
	public static void main(String[] args) {
		write("d:/test/tet/tt/tt.txt","tttttttttttttt");
	}
}
